package com.koron.standard.deviceClasssify.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.koron.standard.deviceClasssify.bean.po.TypeLog;
import com.koron.standard.deviceClasssify.enums.TypeLogChangeTypeEnum;
import com.koron.standard.deviceClasssify.enums.TypeLogClassifyEnum;
import com.koron.standard.deviceClasssify.mapper.TypeLogMapper;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 设备分类变更记录主表(TypeLog)表服务实现类
 *
 * @author jzp
 * @since 2021-07-13 17:13:26
 */
@Service
public class TypeLogService extends ServiceImpl<TypeLogMapper, TypeLog> {

    public void save(TypeLogClassifyEnum classify, String id, String name, TypeLogChangeTypeEnum type) {
        TypeLog typeLog = new TypeLog();
        typeLog.setClassify(classify.getName());
        if (classify == TypeLogClassifyEnum.TYPE) {
            typeLog.setTypeId(id);
            typeLog.setTypeName(name);
        } else if (classify == TypeLogClassifyEnum.PARAM) {
            typeLog.setParamId(id);
            typeLog.setParamName(name);
        }
        typeLog.setChangeType(type.getType());
        typeLog.setChangeTime(new Date());
        super.save(typeLog);
    }
}